package com.cqs.learning.spring.cloud.producer.web;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cqs.learning.spring.cloud.producer.bean.po.HousePrice;
import com.cqs.learning.spring.cloud.producer.bean.vo.ResultMessage;
import com.cqs.learning.spring.cloud.producer.service.HousePriceService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author lixw
 * @Date 6/6/20 12:14 AM
 */
@RestController
@RequestMapping("/house")
public class HousePriceController {

    @Resource
    private HousePriceService service;

    @RequestMapping("/list")
    public ResultMessage list(HousePrice housePrice){
        Page<HousePrice> page = service.page(housePrice);
        return ResultMessage.builder().data(page).build();
    }


    @RequestMapping("/detail")
    public ResultMessage detail(Long id){
        HousePrice byId = service.getById(id);
        ResultMessage result = ResultMessage.builder().data(byId).build();
        if (byId == null) {
            result.setCode(-1);
            result.setMsg("没有找到记录");
        }
        return result;
    }
}
